module.exports = {
  async fetch({ page, args }) {
    if ((args.keyword != '') & (args.keyword != undefined)) {
      url = `http://api.skyrj.com:80/Api2/Dy/GetPageList?SearchKey=${encodeURI(args.keyword)}&pageSize=10&pageIndex=1`
    } else {
      url=`http://baobab.kaiyanapp.com:80/api/v4/categories/videoList?id=${this.args.id}&start=${page||0}&num=10&udid=0e03d29034f5474f981d27cded1b2b65c8316d11`
    }
    
    let resp = await $http.get(url)
    let list =resp.data.itemList
    let items = list.map(data=> {
      return{
        title: data.data.title,
        style: 'live',
        url:url,
        thumb: data.data.cover.feed,
        spanCount: 12,
        label: data.data.category,
        viewerCount: data.data.consumption.collectionCount,
        author: {
          name: data.data.author.name,
        avatar: data.data.author.icon
       },
        route: $route('player', {
          id:data.data.id
        })
      }
    })
    return {
      nextPage: page+ 10,
      items: items
    }
  }
}
